<?php
header("Content-type:text/html;charset=utf-8");

$file = $_GET['filename'];
$file = iconv('utf-8', 'gbk', $file);
$dir = dirname(__FILE__) . '\\file\\';
$file_path = $dir . "/" . $file;


if (!file_exists($file_path)) {
    die("你要下载的文件不存在，请重新下载");
}

$fp = fopen($file_path, "rb");
$file_size = filesize($file_path);
ob_clean();
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length:" . $file_size);
Header("Content-Disposition: attachment; filename=" . basename($file_path));

$contents = fread($fp, $file_size);
echo $contents;
fclose($fp);
